﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfAGVSystem.Model;
using WpfAGVSystem.Model.AGVType;

namespace WpfAGVSystem.Model.AGVType
{
    /// <summary>
    /// 牵引AGV
    /// </summary>
    public class TowClass:AGVSuperClass
    {
      
       private bool Discharging()
        {
            AGVStateServer.Drag_Uinstall = AGVTriggerEnum.Action;//放料
            startime = DateTime.Now;
            while ( !TimeOut)
            {
                Task.Delay(2000).Wait();
                if (IsDecline())
                {
                    Task.Delay(2000).Wait();
                    return true;
                }
            }
          //  LogClass.StaticPush("牵引AGV下降超时！");
            return false;
        }
        private bool Reclaiming()
        {
            AGVStateServer.Drag_Install = AGVTriggerEnum.Action;//取料
            startime = DateTime.Now;
            while ( !TimeOut)
            {
                Task.Delay(2000).Wait();
                if (Islift())
                {
                    Task.Delay(2000).Wait();
                    return true;
                }
            }
         //   LogClass.StaticPush("牵引AGV上升超时！");
            return false;
        }

        public override bool ForkLift(float height, bool isLift)
        {
            if (isLift == true) return Reclaiming();
            return Discharging();
        }
    }
}
